package org.bambrikii.photobank.business.managers;

import java.util.Calendar;

import org.bambrikii.photobank.logging.dao.IFilePreviewCounterDAO;
import org.bambrikii.photobank.logging.model.FilePreviewCounter;
import org.bambrikii.photobank.model.File;
import org.bambrikii.site.base.business.managers.ManagerBase;
import org.bambrikii.site.base.business.managers.core.ManagerException;

public class CounterManager extends
		ManagerBase<FilePreviewCounter, IFilePreviewCounterDAO> {

	public CounterManager(IFilePreviewCounterDAO dao) throws ManagerException {
		super(dao);
	}

	public FilePreviewCounter countFilePreview(File file) {
		FilePreviewCounter fpc = new FilePreviewCounter();
		fpc.setTime(Calendar.getInstance().getTime());
		fpc.setFile(file);
		dao.saveOrUpdate(fpc);
		return fpc;
	}

}
